package com.lvmama.rhino.utils;

import java.io.IOException;
import java.net.URLEncoder;

import sun.misc.BASE64Encoder;


/**
 * 说明：
 * @author yecan
 * @date 2016年7月11日
 */
public class FilenameUtils {
	public static String encodeDownloadFilename(String filename, String agent)
			throws IOException {
		if (agent.contains("Firefox")) {
			filename = "=?UTF-8?B?"
					+ new BASE64Encoder().encode(filename.getBytes("utf-8"))
					+ "?=";
			filename = filename.replaceAll("\r\n", "");
		} else {
			filename = URLEncoder.encode(filename, "utf-8");
			filename = filename.replace("+"," ");
		}
		return filename;
	}

}
